//
//  VailtalReferViewController.m
//  Village
//
//  Created by longrise on 2017/9/11.
//  Copyright © 2017年 程虎. All rights reserved.
//

#import "VailtalReferViewController.h"
#import "ReferViewController.h"
#import "Buttonview.h"
#import "MainTableViewCell.h"
#import "VillageModel.h"
#import "ChineseString.h"//排序
#import "ReferTwoViewController.h"
#import "VillageQViewModel.h"
@interface VailtalReferViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    BOOL push;//跳转
    BOOL sign;//判断特殊城市
    BOOL ft;//是否可以跳转
    BOOL special;
}
@property (nonatomic ,strong) UITableView *mytableview;
@property (nonatomic , strong) Buttonview *buttonview;
@property (nonatomic ,strong) NSMutableArray *searchBtnArr;
@property (nonatomic ,strong) NSMutableArray *sectionarr;
@property (nonatomic ,strong) NSMutableArray *addressarr;
@property (nonatomic ,strong)NSMutableArray *ary;
@property (nonatomic ,assign) NSInteger inta;
@property (nonatomic ,strong) NSMutableDictionary *adderss;
/**
 选择的省,市,区,镇的等级号和地区号
 */
@property (nonatomic ,copy)NSString *provinceorgcode;
@property (nonatomic ,copy)NSString *provinceareaid;
@property (nonatomic ,copy)NSString *cityorgcode;
@property (nonatomic ,copy)NSString *cityareaid;
@property (nonatomic ,copy)NSString *districtorgcode;
@property (nonatomic ,copy)NSString *districtareaid;
@property (nonatomic ,copy)NSString *townorgcode;
@property (nonatomic ,copy)NSString *townareaid;
/**
 索引栏数组
 */
@property(nonatomic,strong)NSMutableArray *indexArray;
@property(nonatomic,strong)NSMutableArray *letterResultArr;
@end

@implementation VailtalReferViewController
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self gatdata];
    
//    push = NO;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    sign = YES;
    ft = NO;
    special = NO;
    // Do any additional setup after loading the view.
    self.title = @"村落查询";
    self.view.backgroundColor = kBackgroundColor;
    UIBarButtonItem *rightBarItem = [[UIBarButtonItem alloc] initWithTitle:@"确认" style:UIBarButtonItemStylePlain target:self action:@selector(onClickedOKbtn)];
    [rightBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                         [UIFont systemFontOfSize:15], NSFontAttributeName,
                                         [UIColor whiteColor], NSForegroundColorAttributeName,
                                         nil]
                               forState:UIControlStateNormal];
    [rightBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                          [UIFont systemFontOfSize:15], NSFontAttributeName,
                                          [UIColor whiteColor], NSForegroundColorAttributeName,
                                          nil]
                                forState:UIControlStateHighlighted];

    self.navigationItem.rightBarButtonItem = rightBarItem;
    [self getdata];
    [self Buildthepage];
}

- (void)gatdata{
     _inta = 0;
    [VillageQViewModel DemandMessageWith:@"" Villorgcod:@"" Success:^(NSArray *valueDict) {
        _ary = [NSMutableArray array];
        NSArray *feedDicts = valueDict;
        NSMutableArray *entities = @[].mutableCopy;
        [feedDicts enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
            [entities addObject:[[VailtallModel alloc] initWithDictionary:obj]];
        }];
        [_ary removeAllObjects];
        for (int i = 0 ; i <entities.count ;i++){
            [_ary addObject:entities[i]];
        }
        _addressarr = [NSMutableArray array];
        VailtallModel *vail = [[VailtallModel alloc] init];
        for (int i = 0 ; i < _ary.count ; i ++){
            vail = _ary[i];
            if (vail.enname ==nil){
            }else{
                [_addressarr addObject:vail.enname];
            }
        }
        self.indexArray = [ChineseString IndexArray:_addressarr];
        self.letterResultArr = [ChineseString LetterSortArray:_addressarr];
        
        dispatch_async(dispatch_get_main_queue(), ^{
            [_mytableview reloadData];
        });
    } failure:^(NSString *error) {
        [MBProgressHUD hideHUDForView:self.navigationController.view];
        [MBProgressHUD showError:error toView:self.navigationController.view];
    }];
//    NSMutableDictionary *entitybean = [NSMutableDictionary dictionary];
//    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
////    [dict setObject:@"110101000000000000" forKey:@"areaid"];
//    [entitybean setValue:dict forKey:@"entitybean"];
//     [MBProgressHUD showMessage:@"正在加载..." toView:self.navigationController.view];
//    [NetRequestClass Post:searchPovareaidURL Parameters:entitybean success:^(id result) {
//        [MBProgressHUD hideHUDForView:self.navigationController.view];
//
//
//        LSLog(@"msg -----  %@",_addressarr);
//        LSLog(@"msg self.indexArray -----  %@", self.indexArray);
//        LSLog(@"msg self.letterResultArr-----  %@",self.letterResultArr);
//    } failure:^(id valueCode, id error) {
//        [MBProgressHUD hideHUDForView:self.navigationController.view];
//        [MBProgressHUD showError:error toView:self.navigationController.view];
//    }];
}
- (void)getdata{
   
    _adderss = [NSMutableDictionary dictionary];
    _searchBtnArr = [NSMutableArray array];
    _sectionarr = [NSMutableArray array];

    [_searchBtnArr addObject:[NSString stringWithFormat:@"#"]];
    for(char i = 'A';i <='Z';i ++){
        [_sectionarr addObject:[NSString stringWithFormat:@"%c",i]];

        [_searchBtnArr addObject:[NSString stringWithFormat:@"%c",i]];
    }
    [_searchBtnArr addObject:[NSString stringWithFormat:@"#"]];
}
- (void)Buildthepage{
    _mytableview = [[UITableView alloc] initWithFrame:CGRectMake(0, 150*kScreenScaleY, kDeviceWidth, KDeviceHeight-214) style:UITableViewStylePlain];
    _mytableview.backgroundColor = kBackgroundColor;
    _mytableview.dataSource = self;
    _mytableview.delegate = self;
    _mytableview.sectionIndexBackgroundColor = [UIColor clearColor];
    _mytableview.sectionIndexColor = K_Anniuhong;
    [self.view addSubview:_mytableview];
    _buttonview= [[Buttonview alloc] initWithFrame:CGRectMake(0, 0, kDeviceWidth, 150*kScreenScaleY)];
    _buttonview.backgroundColor = kBackgroundColor;
    [self.view addSubview:_buttonview];
    
    _mytableview.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];//去除多余空白行
    [_buttonview.province addTarget:self action:@selector(provinceaction) forControlEvents:UIControlEventTouchUpInside];
    [_buttonview.city addTarget:self action:@selector(cityaction) forControlEvents:UIControlEventTouchUpInside];
    [_buttonview.district addTarget:self action:@selector(districtaction) forControlEvents:UIControlEventTouchUpInside];
    [_buttonview.town addTarget:self action:@selector(townaction) forControlEvents:UIControlEventTouchUpInside];
    [_buttonview.village addTarget:self action:@selector(villageeaction) forControlEvents:UIControlEventTouchUpInside];
}
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index
{
    return index;
}
-(NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
{
    return self.indexArray;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
    NSString *key = [self.indexArray objectAtIndex:section];
    return key;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return [self.indexArray count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [(NSMutableArray*)[self.letterResultArr objectAtIndex:section] count];
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 40;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *string = @"cell";
//    VailtallModel *vail = [[VailtallModel alloc] init];
//    vail = _ary[indexPath.row];
    MainTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:string];
    if (cell == nil) {
        cell = [[MainTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:string];
    }
    cell.labName.text = [[self.letterResultArr objectAtIndex:indexPath.section]objectAtIndex:indexPath.row];
    cell.selectionStyle = UITableViewCellSeparatorStyleNone;
    return cell;
}
//右侧索引
//- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView{
//    return _searchBtnArr;
//}
//- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index
//{
//    NSInteger count = 0;
//    for(NSString *header in _searchBtnArr){
//        if([header isEqualToString:title]){
//            return count;
//        }
//        count ++;
//    }
//    return 0;
//}
//- (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
//    return 30;
//}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger) section
{
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kDeviceWidth, 30)];
    view.backgroundColor = kBackgroundColor;
    UILabel *lable = [[UILabel alloc] initWithFrame:CGRectMake(10, 15, 30, 10)];
    lable.text = [self.indexArray objectAtIndex:section];
    lable.font = [UIFont systemFontOfSize:14];
    lable.textColor = [UIColor lightGrayColor];
    [view addSubview:lable];
    return view;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSLog(@"----%@",[[self.letterResultArr objectAtIndex:indexPath.section]objectAtIndex:indexPath.row]);
    VailtallModel *vail = [[VailtallModel alloc] init];
    int y = 0 ;
    for (int i = 0 ; i < _ary.count;i ++)
    {
        vail = _ary[i];
        BOOL res =  [[[self.letterResultArr objectAtIndex:indexPath.section]objectAtIndex:indexPath.row] isEqualToString:vail.enname];
        if (res == YES)
        {
            y = i;
        }
        else
        {
            NSLog(@"不相等");
        }
    }
    vail = _ary[y];
    switch (_inta) {
        case 0:
            ft = NO;//判断特殊城市
            if ([vail.enname isEqualToString:@"北京市"]||[vail.enname isEqualToString:@"重庆市"]||[vail.enname isEqualToString:@"上海市"]||[vail.enname isEqualToString:@"天津市"]){
                special = YES;
            }
            [_buttonview.province setTitle:vail.enname forState:UIControlStateNormal];
            [_adderss setValue:vail.enname forKey:@"province"];
            [_adderss setValue:vail.areaid forKey:@"areaid"];
            _provinceareaid = vail.areaid;
            _provinceorgcode = vail.orgcode;
            [self cityaction];
            break;
        case 1:
         
            if (sign == YES){
                [_buttonview.city setTitle:vail.enname forState:UIControlStateNormal];
                [_adderss setValue:vail.enname forKey:@"city"];
                    [_adderss setValue:vail.areaid forKey:@"areaid"];
                _cityareaid = vail.areaid;
                _cityorgcode = vail.orgcode;
                [self districtaction];
            }
            break;
        case 2:
            if (special == YES){
                ft = YES;
            }
             if (sign == YES){
                 [_buttonview.district setTitle:vail.enname forState:UIControlStateNormal];
                 [_adderss setValue:vail.enname forKey:@"district"];
                     [_adderss setValue:vail.areaid forKey:@"areaid"];
                 _districtareaid = vail.areaid;
                 _districtorgcode = vail.orgcode;
                 [self townaction];
             }
          
            break;
        case 3:
            
            if (sign == YES){
                [_buttonview.town setTitle:vail.enname forState:UIControlStateNormal];
                [_adderss setValue:vail.enname forKey:@"town"];
                [_adderss setValue:vail.areaid forKey:@"areaid"];
                _townareaid = vail.areaid;
                _townorgcode = vail.orgcode;
                [self villageeaction];
            }
          
            break;
        case 4:
            
            if (sign == YES){
                push = YES;
                [_buttonview.village setTitle:vail.enname forState:UIControlStateNormal];
                [_adderss setValue:vail.enname forKey:@"village"];
                [_adderss setValue:vail.areaid forKey:@"areaid"];
            }
            
            break;
        default:
            break;
    }
}
- (void)buttonzhuangtai{
     [_buttonview.province setTitle:@"请选择省" forState:UIControlStateNormal];
     [_buttonview.city setTitle:@"请选择市" forState:UIControlStateNormal];
     [_buttonview.district setTitle:@"请选择区" forState:UIControlStateNormal];
     [_buttonview.town setTitle:@"请选择镇,街道" forState:UIControlStateNormal];
     [_buttonview.village setTitle:@"请选择村,居委会" forState:UIControlStateNormal];
}

#pragma mark - 省份选择
- (void)provinceaction{
     sign = YES;
    
    [self  gatdata];
       dispatch_async(dispatch_get_main_queue(), ^{
        [_mytableview reloadData];
    });
    _inta = 0;
    [self buttonzhuangtai];
}
#pragma mark - 市选择
- (void)cityaction{
    [_buttonview.city setTitle:@"请选择市" forState:UIControlStateNormal];
    [_buttonview.district setTitle:@"请选择区" forState:UIControlStateNormal];
    [_buttonview.town setTitle:@"请选择镇,街道" forState:UIControlStateNormal];
    [_buttonview.village setTitle:@"请选择村,居委会" forState:UIControlStateNormal];
    [_adderss setValue:@"" forKey:@"city"];
    [_adderss setValue:@"" forKey:@"district"];
    [_adderss setValue:@"" forKey:@"town"];
    [_adderss setValue:@"" forKey:@"village"];
    
    if ([[_adderss allKeys] containsObject:@"province"]){
        
        NSMutableDictionary *entitybean = [NSMutableDictionary dictionary];
        NSMutableDictionary *dict = [NSMutableDictionary dictionary];
        [dict setObject:_provinceorgcode forKey:@"orgcode"];
        [dict setObject:_provinceareaid forKey:@"areaid"];
        [entitybean setValue:dict forKey:@"entitybean"];
        
        [NetRequestClass Post:searchCcareaidURL Parameters:entitybean success:^(id result) {
            _ary = [NSMutableArray array];
            NSArray *feedDicts = result[@"data"];
            NSMutableArray *entities = @[].mutableCopy;
            [feedDicts enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
                [entities addObject:[[VailtallModel alloc] initWithDictionary:obj]];
            }];
            
            [_ary removeAllObjects];
            
            for (int i = 0 ; i <entities.count ;i++){
                [_ary addObject:entities[i]];
            }
            _addressarr = [NSMutableArray array];
            VailtallModel *vail = [[VailtallModel alloc] init];
            
            
            for (int i = 0 ; i < _ary.count ; i ++){
                vail = _ary[i];
                if (vail.enname ==nil){
                    
                }else{
                    [_addressarr addObject:vail.enname];
                }
                
            }
            
            self.indexArray = [ChineseString IndexArray:_addressarr];
            self.letterResultArr = [ChineseString LetterSortArray:_addressarr];

            dispatch_async(dispatch_get_main_queue(), ^{
                [_mytableview reloadData];
            });
              sign = YES;
              _inta = 1;
            LSLog(@"msg -----  %@",result);
        } failure:^(id valueCode, id error) {
            [MBProgressHUD hideHUDForView:self.navigationController.view];
            if ([error isEqualToString:@"数据为空"]){
                sign = NO;
                ft = YES;
                 push = YES;
                [MBProgressHUD showError:@"已经到最后了,不需要再选择了" toView:self.navigationController.view];
          
            }else{
                [MBProgressHUD showError:error toView:self.navigationController.view];
            }
        }];
      
    }else{
        [MBProgressHUD hideHUDForView:self.navigationController.view];
        [MBProgressHUD showError:@"请先选择省" toView:self.navigationController.view];
    }
}
#pragma mark - 区选择
- (void)districtaction{
    
    [_buttonview.district setTitle:@"请选择区" forState:UIControlStateNormal];
    [_buttonview.town setTitle:@"请选择镇,街道" forState:UIControlStateNormal];
    [_buttonview.village setTitle:@"请选择村,居委会" forState:UIControlStateNormal];
    

    [_adderss setValue:@"" forKey:@"district"];
    [_adderss setValue:@"" forKey:@"town"];
    [_adderss setValue:@"" forKey:@"village"];
    if ([[_adderss allKeys] containsObject:@"city"]){
        
        NSMutableDictionary *entitybean = [NSMutableDictionary dictionary];
        NSMutableDictionary *dict = [NSMutableDictionary dictionary];
        [dict setObject:_cityorgcode forKey:@"orgcode"];
        [dict setObject:_cityareaid forKey:@"areaid"];
        [entitybean setValue:dict forKey:@"entitybean"];
        
        [NetRequestClass Post:searchCcareaidURL Parameters:entitybean success:^(id result) {
            _ary = [NSMutableArray array];
            NSArray *feedDicts = result[@"data"];
            NSMutableArray *entities = @[].mutableCopy;
            [feedDicts enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
                [entities addObject:[[VailtallModel alloc] initWithDictionary:obj]];
            }];
            [_ary removeAllObjects];
            
            for (int i = 0 ; i <entities.count ;i++){
                [_ary addObject:entities[i]];
            }
            
            
            _addressarr = [NSMutableArray array];
            VailtallModel *vail = [[VailtallModel alloc] init];
            
            for (int i = 0 ; i < _ary.count ; i ++){
                vail = _ary[i];
                if (vail.enname ==nil){
                    
                }else{
                    [_addressarr addObject:vail.enname];
                }
                
            }
            
            self.indexArray = [ChineseString IndexArray:_addressarr];
            self.letterResultArr = [ChineseString LetterSortArray:_addressarr];

            
            dispatch_async(dispatch_get_main_queue(), ^{
                [_mytableview reloadData];
            });
            sign = YES;
                 _inta = 2;
            LSLog(@"msg -----  %@",result);
        } failure:^(id valueCode, id error) {
            [MBProgressHUD hideHUDForView:self.navigationController.view];
            if ([error isEqualToString:@"数据为空"]){
                   sign = NO;
                  ft = YES;
                 push = YES;
                [MBProgressHUD showError:@"已经到最后了,不需要再选择了" toView:self.navigationController.view];
        
            }else{
                [MBProgressHUD showError:error toView:self.navigationController.view];
            }
        }];
        
        
   
        
    }else{
        [MBProgressHUD hideHUDForView:self.navigationController.view];
        [MBProgressHUD showError:@"请先选择市" toView:self.navigationController.view];
    }}
#pragma mark - 镇选择
- (void)townaction{
    push = NO;
    [_buttonview.town setTitle:@"请选择镇,街道" forState:UIControlStateNormal];
    [_buttonview.village setTitle:@"请选择村,居委会" forState:UIControlStateNormal];
    [_adderss setValue:@"" forKey:@"town"];
    [_adderss setValue:@"" forKey:@"village"];
    if ([[_adderss allKeys] containsObject:@"district"]){
        
        NSMutableDictionary *entitybean = [NSMutableDictionary dictionary];
        NSMutableDictionary *dict = [NSMutableDictionary dictionary];
        [dict setObject:_districtorgcode forKey:@"orgcode"];
        [dict setObject:_districtareaid forKey:@"areaid"];
        [entitybean setValue:dict forKey:@"entitybean"];
        
        [NetRequestClass Post:searchCcareaidURL Parameters:entitybean success:^(id result) {
            _ary = [NSMutableArray array];
            NSArray *feedDicts = result[@"data"];
            NSMutableArray *entities = @[].mutableCopy;
            [feedDicts enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
                [entities addObject:[[VailtallModel alloc] initWithDictionary:obj]];
            }];
            
            [_ary removeAllObjects];
            
            for (int i = 0 ; i <entities.count ;i++){
                [_ary addObject:entities[i]];
            }
            
            _addressarr = [NSMutableArray array];
            VailtallModel *vail = [[VailtallModel alloc] init];
            
            for (int i = 0 ; i < _ary.count ; i ++){
                vail = _ary[i];
                if (vail.enname ==nil){
                    
                }else{
                       [_addressarr addObject:vail.enname];
                }
            
            }
            
            self.indexArray = [ChineseString IndexArray:_addressarr];
            self.letterResultArr = [ChineseString LetterSortArray:_addressarr];

            
            
            dispatch_async(dispatch_get_main_queue(), ^{
                [_mytableview reloadData];
            });
            _inta = 3;
            sign = YES;
            LSLog(@"msg -----  %@",result);
        } failure:^(id valueCode, id error) {
            [MBProgressHUD hideHUDForView:self.navigationController.view];
            if ([error isEqualToString:@"数据为空"]){
                 sign = NO;
                 ft = YES;
                 push = YES;
                [MBProgressHUD showError:@"已经到最后了,不需要再选择了" toView:self.navigationController.view];
         
            }else{
                [MBProgressHUD showError:error toView:self.navigationController.view];
            }
        }];
    }else{
        [MBProgressHUD hideHUDForView:self.navigationController.view];
        [MBProgressHUD showError:@"请先选择区" toView:self.navigationController.view];
    }
}

#pragma mark - 村选择
- (void)villageeaction{

    [_adderss setValue:@"" forKey:@"village"];
    if ([[_adderss allKeys] containsObject:@"town"]){
        
        NSMutableDictionary *entitybean = [NSMutableDictionary dictionary];
        NSMutableDictionary *dict = [NSMutableDictionary dictionary];
        [dict setObject:_townorgcode forKey:@"orgcode"];
        [dict setObject:_townareaid forKey:@"areaid"];
        [entitybean setValue:dict forKey:@"entitybean"];
        
        [NetRequestClass Post:searchCcareaidURL Parameters:entitybean success:^(id result) {
            _ary = [NSMutableArray array];
            NSArray *feedDicts = result[@"data"];
            NSMutableArray *entities = @[].mutableCopy;
            [feedDicts enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
                [entities addObject:[[VailtallModel alloc] initWithDictionary:obj]];
            }];
            
            [_ary removeAllObjects];
            
            for (int i = 0 ; i <entities.count ;i++){
                [_ary addObject:entities[i]];
            }
            _addressarr = [NSMutableArray array];
            VailtallModel *vail = [[VailtallModel alloc] init];
            
            for (int i = 0 ; i < _ary.count ; i ++){
                vail = _ary[i];
                if (vail.enname ==nil){
                    
                }else{
                    [_addressarr addObject:vail.enname];
                }
                
            }
            self.indexArray = [ChineseString IndexArray:_addressarr];
            self.letterResultArr = [ChineseString LetterSortArray:_addressarr];
            dispatch_async(dispatch_get_main_queue(), ^{
                [_mytableview reloadData];
            });
            ft = YES;
            sign =  YES;
             push = NO;
           _inta = 4;
            LSLog(@"msg -----  %@",result);
        } failure:^(id valueCode, id error) {
            [MBProgressHUD hideHUDForView:self.navigationController.view];
            if ([error isEqualToString:@"数据为空"]){
                   sign = NO;
                   push = YES;
                   ft = YES;
            [MBProgressHUD showError:@"已经到最后了,不需要再选择了" toView:self.navigationController.view];
            }else{
            [MBProgressHUD showError:error toView:self.navigationController.view];
            }
       }];
     
    }else{
        [MBProgressHUD hideHUDForView:self.navigationController.view];
        [MBProgressHUD showError:@"请先选择镇,街道" toView:self.navigationController.view];
    }
}
- (void)onClickedOKbtn{
    id obj;
    
    if (  ft == YES){
        if (push == YES){
            obj = [LongriseRouter openURL:@"ReferViewController"];
        }else{
            obj = [LongriseRouter openURL:@"ReferTwoViewController"];
        }
        
        if([LongriseRouter isImplLongriseRouterDelegaterWithObject:obj])
        {
            id<LongriseRouterDelegater> delegater = obj;
            if(delegater)
            {
                //进行传值，传入统一的block以供B进行回调
                [delegater setParams:_adderss block:^(id obj) {
                    NSLog(@"回调数据：%@",obj);
                }];
            }
        }
        if (obj && [obj isKindOfClass:[UIViewController class]]) {
            UIViewController *VC = obj;
            VC.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:VC animated:YES];
        }
    }else{
         [MBProgressHUD showError:@"请至少选择镇,街道" toView:self.navigationController.view];
    }
  

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
@end
